using System.ComponentModel.DataAnnotations;
using System.Data.Entity.ModelConfiguration;

namespace WeberTimeTracker.Models.Mapping
{
    public class Project_ContactsMap : EntityTypeConfiguration<Project_Contacts>
    {
        public Project_ContactsMap()
        {
            // Primary Key
            this.HasKey(t => t.Project_Contact_ID);

            // Properties
            // Table & Column Mappings
            this.ToTable("Project_Contacts");
            this.Property(t => t.Project_Contact_ID).HasColumnName("Project_Contact_ID");
            this.Property(t => t.Project_ID).HasColumnName("Project_ID");
            this.Property(t => t.Contact_ID).HasColumnName("Contact_ID");

            // Relationships
            this.HasRequired(t => t.Contact)
                .WithMany(t => t.Project_Contacts)
                .HasForeignKey(d => d.Contact_ID);
            this.HasRequired(t => t.Project)
                .WithMany(t => t.Project_Contacts)
                .HasForeignKey(d => d.Project_ID);

        }
    }
}
